package top.lfyao.designpattern.details.factory.method;

import top.lfyao.designpattern.details.factory.simple.Operation;

public class AlgorithmContext {
    IFactory iFactory;

    // 通过运算符  结合反射获取具体算法类
    public AlgorithmContext(String oparation) {
        this.iFactory= reflexOparation.createOperation(oparation);
    }

    public Operation ContextInterface() {
        return iFactory.createOperation();
    }

    public double getResult(double numberA, double numberB) {
        Operation operation = this.ContextInterface();
        operation.numberA=numberA;
        operation.numberB=numberB;
        return operation.result();
    }
}
